package com.attilax.io;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

public class FileUtil {
	
	public static void main(String[] args) {
		System.out.println(getRltFilename("",""));
	}
	
	
	public static String getRltFilename(String f,String oriDir) {
		  String rltFilename=f.substring(oriDir.length()+1);;
		return rltFilename;
	}


	/**
	attilax    2016楠烇拷9閺堬拷28閺冿拷  娑撳宕�5:38:58
	 * @param f
	 * @param targetDir
	 * @param oriDir
	 */
	public static void copy(String f, String targetDir, String oriDir) {
		//   int splt=f.indexOf(oriDir);
		f=f.trim();
		   String rltFilename=f.substring(oriDir.length()+1);
		   String newname=targetDir+File.separator+rltFilename;
		   try {
			FileUtils.copyFile(new File( f),new File(newname));
		} catch (IOException e) {
			 throw new RuntimeException(e);
		}
		
	}

	public static void move_sf(String f, String targetDir, String oriDir) {
		 try {
			 move(f,targetDir,oriDir);
		} catch (Exception e) {
			 e.printStackTrace();
		}
		
	}
	public static void move(String f, String targetDir, String oriDir) {
		f=f.trim();
		   String rltFilename=f.substring(oriDir.length()+1);
		   String newname=targetDir+File.separator+rltFilename;
		   try {
			FileUtils.moveFile(new File( f),new File(newname));
		} catch (IOException e) {
			 throw new RuntimeException(e);
		}
		
	}

}
